<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('请假列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>请假类型：</label>
                            <select name="leaveType" th:with="type=${@dict.getType('sys_leave_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 95px;">请假开始时间：</label>
                            <input type="text" class="time-input" placeholder="请选择请假开始时间" name="startTime"/>
                        </li>
                        <li>
                            <label style="width: 95px;">请假审批状态：</label>
                            <select name="leaveStatus" th:with="type=${@dict.getType('sys_approval_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary" onclick="$.operate.add()">
                <i class="fa fa-user-times"></i> 我要请假
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var datas = [[${@dict.getType('sys_leave_type')}]];
    var myDatas = [[${@dict.getType('sys_approval_status')}]];
    var editFlag = [[${@permission.hasPermi('system:leave:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:leave:remove')}]];
    var prefix = ctx + "system/leave";

    $(function() {
        var options = {
            url: prefix + "/myLeaveList",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            createUrl: prefix + "/add",
            modalName: "请假",
            columns: [{
                checkbox: true
            },
                {
                    field: 'leaveId',
                    title: '请假单编号',
                    visible: false
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'deptId',
                    title: '部门编号'
                },
                {
                    field: 'belongOrganization',
                    title: '所属组织'
                },
                {
                    field: 'leaveType',
                    title: '请假类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'startTime',
                    title: '请假开始时间'
                },
                {
                    field: 'endTime',
                    title: '请假结束时间'
                },
                {
                    field: 'leaveDays',
                    title: '请假长度'
                },
                {
                    field: 'leaveDetail',
                    title: '请假说明'
                },
                {
                    field: 'fujianAddress',
                    title: '附件地址'
                },
                {
                    field: 'leaveStatus',
                    title: '请假审批状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(myDatas, value);
                    }
                },
                {
                    field: 'userId',
                    title: '员工编号'
                },
                {
                    title: '操作',
                    align: "center",
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.leaveStatus == 0){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.approval(\'' + row.leaveId + '\')"><i class="fa fa-check-square-o"></i>提交审批</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.leaveId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.leaveId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>